package QQ;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5 {

	//MD5加密
	public static String exec(byte[] input) {
		char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
				'B', 'C', 'D', 'E', 'F' };
		char[] c = null;
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.update(input);
			byte[] b = md.digest();
			c = new char[32];
			int p = 0;
			for (int i = 0; i < 16; i++) {
				c[p++] = hex[b[i] >>> 4 & 0xf];
				c[p++] = hex[b[i] & 0xf];
			}
		} catch (NoSuchAlgorithmException e) {
			return null;
		}
		return new String(c);
	}
}
